# coding:UTF-8
# ________________________
# Project_Name:pythonProject
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/4/21 16:11
# Description:
# ________________________
from selenium import webdriver
import time
from selenium.webdriver.common.by import By


def foo1():
    """
    提取新闻元素
    """
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://www.baidu.com/")
    # 通过linktext定位元素
    # driver.find_element(By.LINK_TEXT, "隐私设置").click()
    # time.sleep(3)
    # # 通过Parttal_link_text定位元素
    # driver.find_element(By.PARTIAL_LINK_TEXT, "更多").click()
    # time.sleep(3)
    # # 通过css selector定位元素
    # driver.find_element(By.CSS_SELECTOR, "#s-top-left > a:nth-child(1)").click()
    # time.sleep(3)

    # driver.find_element(By.XPATH, '//*[@id="s-user.csv-setting-menu"]/a[4]').click()
    # time.sleep(2)

    driver.find_element(By.XPATH, '').click()
    time.sleep(2)

    driver.quit()

def foo2():
    """
    提取hao123元素
    """
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://www.baidu.com/")
    driver.find_element(By.LINK_TEXT,"hao123").click()
    time.sleep(3)
    driver.find_element(By.PARTIAL_LINK_TEXT, "hao").click()
    time.sleep(3)
    driver.find_element(By.CSS_SELECTOR, "#s-top-left > a:nth-child(2)").click()
    time.sleep(3)

    driver.quit()

    # // *[ @ id = "s-top-left"] / a[2]
# /html/body/div[1]/div[1]/div[3]/a[2]
# //*[@id="s-usersetting-top"]
# //*[@id="s-user.csv-setting-menu"]/div/a[1]/span
# //*[@id="s-top-more"]/div[3]/a[2]/div
# //*[@id="s-top-more"]/div[1]/a[2]/div
# //*[@id="s-top-left"]/div/a
# //*[@id="u"]/a[2]
# //*[@id="s-user.csv-setting-menu"]/div/a[1]/span
# //*[@id="s-user.csv-setting-menu"]/a[1]
# //*[@id="u1"]/div[2]/span
# //*[@id="s-top-loginbtn"]
# //*[@id="lg"]


if __name__ == "__main__":
    foo1()
    # foo2()